import {
  get,
  post,
  put,
} from "./base_service"


/**
 * 预约相关接口
 *
 * allen  2021-08-24
 */


 /**
  * 创建一个新的预约
  * @param {*} data 
  */
const createNewBooking = (data) => {
  return new Promise((resolve, reject) => {
    post("/booking",data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 查询我的预约列表
 * @param {*} page 
 * @param {*} pageSize 
 */
const queryMyBookingList = (page,pageSize) => {
  return new Promise((resolve, reject) => {
    get("/booking?page=" + page + "&pageSize=" + pageSize).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}


module.exports = {
  createNewBooking,
  queryMyBookingList
}
